package com.foreknow.oop.hw2;

/**
 * 矩形类
 */
public class Rectangle {
    private int length; // 长
    private int width;  // 宽

    public Rectangle(int length, int width) {
        this.length = length;
        this.width = width;
    }

    public int getLength() {
        return length;
    }

    public void setLength(int length) {
        this.length = length;
    }

    public int getWidth() {
        return width;
    }

    public void setWidth(int width) {
        this.width = width;
    }

    /**
     * 面积
     * @return
     */
    public int getArea(){
        return length*width;
    }

    /**
     * 周长
     * @return
     */
    public int getPer(){
        return 2*(length+width);
    }

    /**
     * 输出长、宽、面积、周长
     */
    public void showAll(){
        System.out.printf("矩形的长：%d\n",length);
        System.out.printf("矩形的宽：%d\n",width);
        System.out.printf("矩形的面积：%d\n",getArea());
        System.out.printf("矩形的周长：%d\n",getPer());
    }

    public static void main(String[] args) {
        Rectangle rectangle = new Rectangle(20, 20);
        rectangle.showAll();
    }
}
